@extends('layouts.admin')

@section('css')

@endsection

@section('content')
    <section class="content" id="app">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <h1 v-text="message"></h1>
                        <table class="table">
                            <thead>
                            <tr>
                                <td>任务ID</td>
                                <td>任务名称</td>
                                <td>标签</td>
                                <td>创建时间</td>
                                <td>发布时间</td>
                                <td>截止时间</td>
                                <td>审核时长</td>
                                <td>发布数量</td>
                                <td>已领数量</td>
                                <td>状态</td>
                                <td>发布者</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($lists as $key => $value)
                                <tr>
                                    <td>{{$value['id']}}</td>
                                    <td>{{$value['title']}}</td>
                                    <td>
                                        @if(!empty($value['label_arr']) && is_array($value['label_arr']))
                                            @foreach($value['label_arr'] as $k => $v)
                                                <span>{{$labels[$v]}}</span>
                                            @endforeach
                                        @endif
                                    </td>
                                    <td>{{$value['created_at']}}</td>
                                    <td>{{$value['release_time']}}</td>
                                    <td>{{$value['deadlime']}}</td>
                                    <td>{{$value['hours']}}小时</td>
                                    <td>{{$value['number']}}</td>
                                    <td>{{$value['used_nums']}}</td>
                                    <td>{{$states[$value['state']]}}</td>
                                    <td>{{$value['username']}}</td>
                                    <td>
                                        <a href="/admin/task/show/{{$value['id']}}">查看详情</a>
                                        <a href="/admin/task/edit/{{$value['id']}}">编辑</a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection

@section('script')
    <script type="text/javascript">

            Vue.use(VueResource)
            var app = new Vue({
                el: '#app',
                data: {
                    message: 'Hello Vue!'
                },
                methods : {
                    sendData : function(){
                        send();
                    }
                }
            })

            function send() {
                app.$http.get('http://211.149.193.19:8080/api/customers')
                        .then(function (response) {
                            console.log(response)
                        })
                        .catch(function(response) {
                            console.log(response)
                        })
            }

    </script>
@endsection